// import axios from 'axios'

import { apiGet } from "@/assets/js/api"

const DataStore = {
  namespaced: true,
  state: {
    userData: {},
    countryList: [],
    countryTwoImg:[],
  },
  mutations: {
    changeCountryList (state, change) {
      state.countryList = change
    },
    changeCountryTwoImg (state, change) {
      state.countryTwoImg = change
    },
    changeCountryID (state, change) {
      state.countryID = change
    },
  },
  actions: {
    getCountryList(store){
      apiGet('/nps/nation/getContinent').then(res => {
        store.commit('changeCountryList', res.data)
      })
    },
    getCountryTwoImg(store, params){
      store.commit('changeCountryTwoImg', apiGet('/nps/image/getimage', params))
    },
  },
  getters: {
    searchCountry (state) {
      return (search) => {
        return state.countryList.filter(item => item.continentName==search)[0].npsCountryVoList
      }
    },
    // searchOtherClass (state) {
    //   return (data) => {
    //     return state.myFolder[data.index].haveClass.filter(item => item.name.includes(data.select))
    //   }
    // }
  }
}

export default DataStore
